package cn.fl.dk.web.transform;

import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.DateUtils;
import cn.fl.dk.base.transform.BaseDkBillInfoVOTransform;
import cn.fl.dk.facade.dto.DkBillInfoDTO;
import cn.fl.dk.web.vo.DkBillInfoVO;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @Description: 垫款单(DK_BILL_INFO) 转换器
 * @Description: VO是客户端传递数据到服务端进行转换的数据 
 * @Description: VO转换数据变成DTO传递到服务端 
 * @Description: VO不能在服务端出现
 */
public class DkBillInfoVOTransform extends BaseDkBillInfoVOTransform {


	/**
	 * DTO 转  VO
	 * @return DkBillInfoVO
	 */
	public static DkBillInfoVO toVO(DkBillInfoDTO dto) {
		DkBillInfoVO  vo = baseToVO(dto);
		//设置自定义扩展属性
		Date crtTm = dto.getCrtTm();
		if(crtTm != null){
			vo.setCrtTmStr(DateUtils.formatDateToString(crtTm,DateUtils.YYYY_MM_DD));
		}
		return vo;
	}

	/**
	 * VO 转 DTO
	 * @return DkBillInfoDTO
	 */
	public static DkBillInfoDTO toDTO(DkBillInfoVO vo) {
		DkBillInfoDTO dto = baseToDTO(vo);

		//设置自定义扩展属性
		return dto;
	}
	
	/**
	 * DTO集合 转 VO集合
	 * @return List<DkBillInfoVO>
	 */
	public static List<DkBillInfoVO> toVOList(List<DkBillInfoDTO> list) {
		List<DkBillInfoVO>  voList = new ArrayList<DkBillInfoVO>();
		if(CollectionUtils.isNotEmpty(list)){
			for (DkBillInfoDTO dto : list) {
				voList.add(toVO(dto));
			}
		}
		return voList;
	}
	
	/**
	 * VO集合 转 DTO集合
	 * @param list List<DkBillInfoVO>
	 * @return List<DkBillInfoDTO>
	 */
	public static List<DkBillInfoDTO> toDTOList(List<DkBillInfoVO> list) {
		List<DkBillInfoDTO>  dtoList = new ArrayList<DkBillInfoDTO>();
		if(CollectionUtils.isNotEmpty(list)){
			for (DkBillInfoVO vo : list) {
				dtoList.add(toDTO(vo));
			}
		}
		return dtoList;
	}
}
